﻿using System.Windows;
using Microsoft.Practices.Prism.Events;
using Microsoft.Practices.Prism.Logging;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.ServiceLocation;
using Motar.Desktop.Injecting;
using Motar.Desktop.Logging;
using Motar.UnityExtensions;

namespace Motar.Desktop.UnityExtensions
{

    /// <summary>
    /// 
    /// </summary>
    public class UnityDesktopBootstrapperExtension<TInitializer, TShell> : UnityBootstrapperExtension where TInitializer : UnityDesktopInitializer<TShell> where TShell : Window
    {

        /// <summary>
        /// 
        /// </summary>
        protected override void ConfigureOthers()
        {
            base.ConfigureOthers();

            RegisterIfMissing<ILoggerFacade, LoggerFacade>(true);

            RegisterIfMissing<IServiceLocator, ServiceLocatorFacade>(true);

            RegisterIfMissing<RegionAdapterMappings, RegionAdapterMappings>(true);

            RegisterIfMissing<IRegionManager, RegionManager>(true);

            RegisterIfMissing<IEventAggregator, EventAggregator>(true);

            RegisterIfMissing<IRegionViewRegistry, RegionViewRegistry>(true);

            RegisterIfMissing<IRegionBehaviorFactory, RegionBehaviorFactory>(true);

            RegisterIfMissing<IRegionNavigationJournalEntry, RegionNavigationJournalEntry>(false);

            RegisterIfMissing<IRegionNavigationJournal, RegionNavigationJournal>(false);

            RegisterIfMissing<IRegionNavigationService, RegionNavigationService>(false);

            RegisterIfMissing<IRegionNavigationContentLoader, RegionNavigationContentLoader>(true);
        }

        /// <summary>
        /// 
        /// </summary>
        protected override void ConfigureApplication()
        {
            RegisterIfMissing<IApplicationInitializer, TInitializer>(false);
        }
    }
}
